package com.ycsd.invest.order.business.listplugin;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.control.events.BeforeClickEvent;
import kd.bos.form.events.BeforeCreateListDataProviderArgs;
import kd.bos.form.events.HyperLinkClickArgs;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.events.ListRowClickEvent;
import kd.bos.list.plugin.AbstractMobListPlugin;
import kd.bos.mvc.list.ListDataProvider;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;

import java.util.List;

/**
 * @Descrіption:移动列表
 * @Author: yn
 * @Date: 2025/6/20 15:35
 */
public class TestMobListPlugin extends AbstractMobListPlugin {

    @Override
    public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {
        args.setListDataProvider(new ListDataProvider() {
            @Override
            public DynamicObjectCollection getData(int i, int j) {
                DynamicObjectCollection data = super.getData(i, j);
                if(data.size() > 0 && data.get(0).getDataEntityType().getProperties().containsKey("remark")) {
                    for (DynamicObject dynamicObject : data) {
                        dynamicObject.set("remark", "移动列表插件设置默认备注");
                    }
                }
                return data;
            }
        });
    }

    //设置过滤器
    @Override
    public void setFilter(SetFilterEvent e) {
        List<QFilter> qFilters = e.getQFilters();
        qFilters.add(new QFilter("amount", QCP.large_equals, 1000));
    }

    @Override
    public void listRowClick(ListRowClickEvent evt) {
        evt.setCancel(true);
        this.getView().showMessage("不能查看详情");
    }

    @Override
    public void listRowDoubleClick(ListRowClickEvent evt) {
        evt.setCancel(true);
        this.getView().showMessage("双击也不能查看详情");
    }
}
